﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SimpleChat
{
    public partial class ChatPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxChatDataContext context = new AjaxChatDataContext();
            this.ListView1.DataSource = context.Messages;
            this.ListView1.DataBind();
        }

        protected void ButtonSend_Click(object sender, EventArgs e)
        {
            AjaxChatDataContext context = new AjaxChatDataContext();
            Message newMessage = new Message()
            {
                Message1 = Message.Text
            };
            context.Messages.InsertOnSubmit(newMessage);
            context.SubmitChanges();
            Message.Text = String.Empty;
            Message.Focus();
        }
    }
}